package app.purchase.a571xz.com.myandroidframe.httpservice.base;

import android.os.Parcel;
import android.os.Parcelable;

import lombok.Data;

@Data
public class BaseResponse implements Parcelable {
    private AppException exception;
    private boolean success;
    private String body;

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.exception, flags);
        dest.writeByte(this.success ? (byte) 1 : (byte) 0);
        dest.writeString(this.body);
    }

    public BaseResponse() {
    }

    protected BaseResponse(Parcel in) {
        this.exception = in.readParcelable(AppException.class.getClassLoader());
        this.success = in.readByte() != 0;
        this.body = in.readString();
    }

    public static final Creator<BaseResponse> CREATOR = new Creator<BaseResponse>() {
        @Override
        public BaseResponse createFromParcel(Parcel source) {
            return new BaseResponse(source);
        }

        @Override
        public BaseResponse[] newArray(int size) {
            return new BaseResponse[size];
        }
    };
}
